package com.hexiang.domain;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@Data
@AllArgsConstructor
@Builder
@NoArgsConstructor
public class CommonResponse<T extends Serializable> implements Serializable {
    /**
     * 响应的状态码
     */
    private int code;
    /**
     * 响应的响应体
     */
    private T body;
    /**
     * 是否成功
     */
    private boolean succ;
    /**
     * 描述信息
     */
    private String msg;

    public static CommonResponse<Serializable> fail(int code, String message) {
        CommonResponse<Serializable> commonResponse = new CommonResponse<>();
        commonResponse.setCode(code);
        commonResponse.setMsg(message);
        return commonResponse;
    }
}